package com.uex.dev.manage.admin.controller;

import com.uex.dev.manage.admin.service.IDeviceRobotService;
import com.uex.dev.manage.admin.service.IDeviceUhubService;
import com.uex.dev.manage.admin.vo.device.RobotInfo;
import com.uex.dev.manage.admin.vo.device.UhubInfo;
import com.uex.dev.manage.common.base.ModelResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @author lzs
 * @create 2024/03/06
 * @description
 */
@CrossOrigin(origins = "*", maxAge = 3600)
@Tag(name = "设备能力Controller")
@RestController
public class DeviceCapController {
    @Resource
    private IDeviceRobotService deviceRobotService;
    @Resource
    private IDeviceUhubService uhubService;

    @Operation(description = "查看收单机能力信息")
    @GetMapping("/robot/feature")
    public ModelResult<RobotInfo> getRobotInfo(@RequestParam Integer deviceId) {
        return new ModelResult<>(deviceRobotService.getRobotInfo(deviceId));
    }

    @Operation(description = "更新收单机能力信息")
    @PostMapping("/robot/feature")
    public ModelResult updateRobot(@RequestBody RobotInfo robotUpdateInfoReq) {
        deviceRobotService.updateRobot(robotUpdateInfoReq);
        return ModelResult.SUCCESS_RESULT;
    }

    @Operation(description = "查看云盾能力信息")
    @GetMapping("/uhub/feature")
    public ModelResult<UhubInfo> getUhubInfo(@RequestParam Integer deviceId) {
        return new ModelResult<>(uhubService.getUhubInfo(deviceId));
    }

    @Operation(description = "更新云盾能力信息")
    @PostMapping("/uhub/feature")
    public ModelResult updateUhubInfo(@RequestBody UhubInfo uhubUpdateInfoReq) {
        uhubService.updateUhub(uhubUpdateInfoReq);
        return ModelResult.SUCCESS_RESULT;
    }
}

